﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NodeSource.Executor
{
    public enum FieldType
    {
        Int = 0,
        Float = 1,
        Double = 2,
        Char = 3,
        Varchar = 4,
        Date = 5,
        File = 6,
        Binary = 7,
        Image = 8
    }

    public class Field
    {
        public String Name { get; set; }
        public String NodeSourceName { get; set; }
        public FieldType FieldType { get; set; }

        public static int Compare(object left, object right, FieldType leftFieldType, FieldType rightFieldType, Operator oOperator)
        {
            if ((int)leftFieldType < 4 && (int)rightFieldType < 4)
                return (int)(double.Parse(right.ToString()) - double.Parse(left.ToString()));
            else if ((int)leftFieldType == 5 || (int)rightFieldType == 5)
                return DateTime.Compare(DateTime.Parse(left.ToString()), DateTime.Parse(right.ToString()));
            else if ((int)leftFieldType == 4 || (int)rightFieldType == 4)
                return String.Compare(left.ToString(), right.ToString());

            return -1;
        }
    }
}
